/* Project: POPS
 * CS 279, Vanderbilt University
 * by: Igor I. Ges, Michael S. Parrish, Mark E. Sakauye
 *
 *  This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.popsDB.java.example;

import java.math.*;
import java.util.Date;
import java.util.Collection;
import com.popsDB.java.dao.OrdersDao;
import com.popsDB.java.dto.Orders;
import com.popsDB.java.exceptions.OrdersDaoException;
import com.popsDB.java.factory.OrdersDaoFactory;

public class OrdersTests
{
	public static void main(String[] arg) throws Exception
	{
		// Uncomment one of the lines below to test the generated code
		
		findAll();
		findWhereOrderIDEquals(1);
		findWhereCustomerIDEquals(1);
	}

	public static void findAll()
	{
		try {
			OrdersDao _dao = getOrdersDao();
			Orders _result[] = _dao.findAll();
			System.out.println("\n ******* Test Find All Orders ******");
			int test = 1;
			
			if (_result[0].getOrderID() == test) {
				System.out.println("PASSED\n");
			}
			else {
				System.out.println("FAILED\n");
			}
		
		}
		catch (Exception _e) {
			_e.printStackTrace();
		}
		
	}

	public static void findWhereOrderIDEquals(int orderID)
	{
		try {
			OrdersDao _dao = getOrdersDao();
			Orders _result[] = _dao.findWhereOrderIDEquals(1);
			System.out.println("\n ****** Test Find Where Order ID = " +
					orderID + "******");
			int count = 0;
			for (int i = 0; i < _result.length; i++) {
				if (_result[i].getOrderID() != orderID) {
					count = count + 1;
				}
			}
			if (count == 0) {
				System.out.println("PASSED\n");
			}
			else {
				System.out.println("FAILED\n");
			}
		}
		catch (Exception _e) {
			_e.printStackTrace();
		}
		
	}

	public static void findWhereCustomerIDEquals(int customerID)
	{
		try {
			OrdersDao _dao = getOrdersDao();
			Orders _result[] = _dao.findWhereCustomerIDEquals(1);
			
			System.out.println("\n ****** Test Find Where Customer ID = " 
					+ customerID + " ******");
			int count = 0;
			for (int i = 0; i < _result.length; i++) {
				if (_result[i].getCustomerID() != customerID) {
					count = count + 1;
				}
			}
			if (count == 0) {
				System.out.println("PASSED\n");
			}
			else {
				System.out.println("FAILED\n");
			}
		
		}
		catch (Exception _e) {
			_e.printStackTrace();
		}
		
	}

	public static OrdersDao getOrdersDao()
	{
		return OrdersDaoFactory.create();
	}
}
